#ifndef _GAMEOBJECT_H
#define _GAMEOBJECT_H

#include "FrameWork.h"
#include "SweptAABB.h"
enum EObjectType
{
	EMario,
	EMushroom_Red,
	EMushroom_Green,
	EStar,
	ELand,
	EBreakBrick,
	EFungi,
	ECoin,
	EFlower,
	ETurtle,
	EFlowerMonster,
	EL_Brick,
	EL_Block,
	EL_Land1,
	EL_Land2,
	EL_Land3,
	EL_PiPe,
	EL_BarUp,
	EL_BarDown,
	EQuestionBox,
	EQuestionBox_Red,
	EQuestionBox_Green,
	EQuestionBox_Flower,
	EQuestionBox_Star,
	EPartBrick,
	EBullet,
	ESight,
	ECloud,
	EGrass,
	EFence,
	EMoutain,
	EPipe,
	EPipe_Down,
	EPipe_Up,
	EPipe_Right,
	EPipe_BotTom,
	EGoal
};

enum EState
{
	Alive,
	Move,
	Die,
	Breaking,
	Stand,
	Hit,
	KickUp,
	Blocked,
	NoCheckCollision,
	NoUpdate
};

enum ECollisionDirect
{
	Colls_None,
	Colls_Left,
	Colls_Right,
	Colls_Bot,
	Colls_Top
};

enum EKind
{
	EDynamic,
	EStatic,
	ESolid,
	EScene
};
class GameObject
{
protected:	
	EState m_state; //trang thai cua doi tuong
	//bool m_isDie; // if it dies.
	EObjectType m_type;	// type of object
	CSprite *m_pSprite; // object'sprite
	D3DXVECTOR2 m_position; // object' position
	EDirection m_direction; //huong di chuyen
	D3DXVECTOR2 m_velocity; //van toc
	SpriteEffect m_effect;
	float rotate;
	bool m_isFall;
	bool canUpdate;

	//new
	int _id;
	// tools
	//static list<GameObject*> _creatingAfterObjects;
public:
	static list<GameObject*> _creatingAfterObjects;
	static void RemoveDiedObject(); // remove died object in _creatingAfterObjects

	// constructor destructor
	GameObject(D3DXVECTOR2 , EObjectType, EState state = Alive);
	GameObject(D3DXVECTOR2 , EObjectType,int id, EState state);
	virtual ~GameObject();
	//Update and Draw method
	
	virtual void Update(float ); 
	virtual void UpdateCollision(list<GameObject*> , float);
	virtual ECollisionDirect CheckCollision(GameObject* ,float, float&); //Kiem tra va tra ve huong va cham voi other object va thoi gian va cham	
	virtual void Draw();
	
	//Get , set method
	EDirection GetDirection();
	void SetDirection(EDirection di);

	D3DXVECTOR2 GetPosition();
	void SetPosition(D3DXVECTOR2 pos);

	D3DXVECTOR2 GetVelocity();
	void SetVelocity(D3DXVECTOR2 vel);

	ECollisionDirect GetCollisionDirect(float normalx, float normaly);

	virtual CRect GetBound() const; // rectangle bounds the object

	virtual Box GetBox();

	EObjectType GetObjectType() const; // object type	

	CSprite* GetSprite();

	EState GetObjectState();
	void SetObjectState(EState);
	EKind GetKindOfObject();

	virtual EObjectType GetRealObjectType(){ return m_type;};
	virtual void SetCanUpdate(bool value){canUpdate = value;}
	
	CRect GetBoundCheckCollision();
	void SetFall(bool isfall);

};
#endif